package two;

class People {
    String name;
    int age;
    //构造方法
    People(String name, int age) {
        this.name = name;
        this.age = age;
    }

    void say() {
        System.out.println("我叫" + name + ",今年" + age + "岁");
    }
}

class Student extends People {
    String stuId;
    //构造方法
    Student(String name, int age, String stuId) {
        super(name, age);                                    //super()调用超类构造方法，必须位于派生类构造方法中的第1行
        this.stuId = stuId;
    }
//方法的重写
    void say() {
        System.out.println("我叫" + name + ",今年" + age + "岁，我的学号是" + stuId);
    }
}
public class OverRide2 {
    public static void main(String[] args) {
        People zs = new Student("张三", 25, "001");
        zs.say();
        People ls = new People("李四",80);
        ls.say();
    }
}
